import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.*;
import org.junit.Test;

public class simple {
    @Test
    public void simpleTest() throws Exception {
        String str;
        WebClient webClient = new WebClient();
        //htmlunit 对css和javascript的支持不好，所以请关闭之
        webClient.getOptions().setJavaScriptEnabled(false);
        webClient.getOptions().setCssEnabled(false);
        //获取页面
        HtmlPage page = webClient.getPage("http://login.lexun.com/login/login.php");
        System.out.println(page.asText());
        HtmlForm form = page.getForms().get(0);
        HtmlTextInput  num = form.getInputByName("num");
        num.setValueAttribute("18270911219");
        HtmlPasswordInput  pwd = form.getInputByName("pwd");
        pwd.setValueAttribute("ljc940501");
        HtmlInput submit = form.getInputsByValue("登录").get(0);
        HtmlPage  page1 = submit.click();
        System.out.println(page1.asText());
    }
}
